﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SpringStudio.Common;
using SpringStudio.DAL;
using Sdepci.InfoCode.BLL.CodeIndex;

namespace Sdepci.InfoCode.Web.CodeIndex
{
    public partial class DictDelete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (this.Request.QueryString["DictGuid"] != null && this.Request.QueryString["DictGuid"].Trim().Length > 0)
                {
                    Dict dict = new Dict(this.Request.QueryString["DictGuid"].Trim());
                    this.lblDictName.Text = dict.DictCode + "-" + dict.DictText;
                }
            }
        }

        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            bool result = false;
            if (this.Request.QueryString["DictGuid"] != null && this.Request.QueryString["DictGuid"].Trim().Length > 0)
            {
                DictManager dictManager = new DictManager();
                if (!dictManager.ExistChild(this.Request.QueryString["DictGuid"].Trim()))
                {
                    result = dictManager.Delete(this.Request.QueryString["DictGuid"].Trim());
                }
            }
            string msg = result ? "字典删除成功！" : "字典删除失败！";
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script language=\"javascript\">alert(\"" + msg + "\");self.returnValue=true;self.close();</script>");
        }
    }
}
